using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Xoohoo.Repositories.SqlServerEF.Entities;

namespace Xoohoo.Repositories.SqlServerEF.Mapping
{
	public class SiteMap : EntityTypeConfiguration<Site>
	{
		public SiteMap()
		{
			// Primary Key
			this.HasKey(t => t.SiteID);

			// Properties
			this.Property(t => t.SiteName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.SiteHost)
				.IsRequired()
				.HasMaxLength(100);
				
			this.Property(t => t.SiteTitle)
				.IsRequired()
				.HasMaxLength(200);
				
			this.Property(t => t.SiteKeywords)
				.IsRequired()
				.HasMaxLength(200);
				
			this.Property(t => t.SiteDescription)
				.IsRequired()
				.HasMaxLength(500);
				
			this.Property(t => t.Copyright)
				.IsRequired()
				.HasMaxLength(1000);
				
			this.Property(t => t.FaviconUrl)
				.IsRequired()
				.HasMaxLength(100);
				
			this.Property(t => t.PageTitleSeparator)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.SkinsPath)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.AdminPath)
				.IsRequired()
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Site");
			this.Property(t => t.SiteID).HasColumnName("SiteID");
			this.Property(t => t.SiteName).HasColumnName("SiteName");
			this.Property(t => t.SiteHost).HasColumnName("SiteHost");
			this.Property(t => t.SiteTitle).HasColumnName("SiteTitle");
			this.Property(t => t.SiteKeywords).HasColumnName("SiteKeywords");
			this.Property(t => t.SiteDescription).HasColumnName("SiteDescription");
			this.Property(t => t.Copyright).HasColumnName("Copyright");
			this.Property(t => t.FaviconUrl).HasColumnName("FaviconUrl");
			this.Property(t => t.PageTitleSeparator).HasColumnName("PageTitleSeparator");
			this.Property(t => t.SkinsPath).HasColumnName("SkinsPath");
			this.Property(t => t.AdminPath).HasColumnName("AdminPath");
		}
	}
}

